from django import forms
from django.forms import ModelForm

from helloWorld.models import StudentInfo


# 定义学生form表单
class StudentForm(ModelForm):
    class Meta:  # 配置中心
        model = StudentInfo  # 导入model
        # fields = '__all__'  # 代表所有字段
        fields = ['name', 'age']
        widgets = {
            'name': forms.TextInput(attrs={'id': 'name', 'class': 'inputClass'}),
            'age': forms.NumberInput(attrs={'id': 'age'})
        }

        labels = {  # 指定标签
            'name': '姓名',
            'age': '年龄'
        }
